// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 新增码表 新增码表 POST /codeTable/add */
export async function addCodeTableUsingPost(
  body: dataFactory.DTO4,
  options?: { [key: string]: any },
) {
  return request<dataFactory.R>('/codeTable/add', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除码表 根据ID删除码表 DELETE /codeTable/delete/${param0} */
export async function deleteCodeTableUsingDelete(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: dataFactory.deleteCodeTableUsingDELETEParams,
  options?: { [key: string]: any },
) {
  const { codeId: param0, ...queryParams } = params;
  return request<dataFactory.R>(`/codeTable/delete/${param0}`, {
    method: 'DELETE',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 下载码表模板 下载码表模板文件 GET /codeTable/downloadTemplate */
export async function downloadCodeTableTemplateUsingGet(options?: {
  [key: string]: any;
}) {
  return request<dataFactory.InputStreamResource>(
    '/codeTable/downloadTemplate',
    {
      method: 'GET',
      ...(options || {}),
    },
  );
}

/** 文件导入 文件导入 POST /codeTable/fileInput */
export async function fileInputUsingPost(
  body: {},
  file?: File,
  options?: { [key: string]: any },
) {
  const formData = new FormData();

  if (file) {
    formData.append('file', file);
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele];

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''));
        } else {
          formData.append(ele, JSON.stringify(item));
        }
      } else {
        formData.append(ele, item);
      }
    }
  });

  return request<dataFactory.R>('/codeTable/fileInput', {
    method: 'POST',
    data: formData,
    requestType: 'form',
    ...(options || {}),
  });
}

/** 根据ID获取码表 根据ID获取码表信息 GET /codeTable/getById/${param0} */
export async function getCodeTableByIdUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: dataFactory.getCodeTableByIdUsingGETParams,
  options?: { [key: string]: any },
) {
  const { codeId: param0, ...queryParams } = params;
  return request<dataFactory.R>(`/codeTable/getById/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 获取码表 根据ID获取码表信息 GET /codeTable/getList */
export async function getCodeTableUsingGet(options?: { [key: string]: any }) {
  return request<dataFactory.R>('/codeTable/getList', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 分页查询码表列表 分页查询码表列表 GET /codeTable/pageList */
export async function listCodeTablesUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: dataFactory.listCodeTablesUsingGETParams,
  options?: { [key: string]: any },
) {
  return request<dataFactory.R>('/codeTable/pageList', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 更新码表 更新码表信息 PUT /codeTable/update */
export async function updateCodeTableUsingPut(
  body: dataFactory.DTO2,
  options?: { [key: string]: any },
) {
  return request<dataFactory.R>('/codeTable/update', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 更新码表状态 更新码表状态 PUT /codeTable/updateStatus/${param0} */
export async function updateCodeTableStatusUsingPut(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: dataFactory.updateCodeTableStatusUsingPUTParams,
  options?: { [key: string]: any },
) {
  const { codeId: param0, ...queryParams } = params;
  return request<dataFactory.R>(`/codeTable/updateStatus/${param0}`, {
    method: 'PUT',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 批量更新码表状态 批量更新码表状态 PUT /codeTable/updateStatusBatch */
export async function updateCodeTableStatusBatchUsingPut(
  body: number[],
  options?: { [key: string]: any },
) {
  return request<dataFactory.R>('/codeTable/updateStatusBatch', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
